package com.demo.rpc;

import com.demo.rpc.service.HelloService;
import com.demo.rpc.service.impl.HelloServiceImpl;

import java.io.IOException;
import java.net.InetSocketAddress;

/**
 * Created by hunter
 *
 * @Description rpc test
 */
public class MainTest {

    public static void main(String[] args) {
        // 启动一个线程来保持server 端
        new Thread(() -> {
            try {
                Server serviceServer = new DefaultSever(8088);
                serviceServer.register(HelloService.class, HelloServiceImpl.class);
                serviceServer.start();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }).start();

        HelloService service = Client.getRemoteProxyObj(HelloService.class, new InetSocketAddress("localhost", 8088));
        System.out.println(service.sayHi("test"));
        System.out.println(service.sayHi("test2"));
    }
}